import {ADD_PERSON} from '../constant'

const initState = [{id:'001',name:'海峰',age:18}]

export default function personReducer(preState=initState,action){
	//从action中读取type、data
	const {type,data} = action 
	//根据type类型决定如何加工状态
	switch (type) {
		case ADD_PERSON: //如果是添加一个人
			return [data,...preState]
		default:
			return preState //初始化状态
	}
}
